//
//  YWConcernBtn.m
//  YueshengToutiao
//
//  Created by jun peng on 2021/12/28.
//  Copyright © 2021 YW. All rights reserved.
//

#import "YWConcernBtn.h"

@implementation YWConcernBtn



-(void)awakeFromNib{
    [super awakeFromNib];
    
    [self setTitleColor:YWColor(255, 90, 0) forState:UIControlStateNormal];
    
    self.layer.cornerRadius = 12;
    
    self.layer.borderColor = YWColor(255, 90, 0).CGColor;
    
    self.layer.borderWidth = 1;
    
    
}

-(void)setBtnType:(YWBtnType)btnType{
    
    _btnType = btnType;
    
    
    self.layer.cornerRadius = 17;
    self.layer.borderWidth = 0;
    
    switch (btnType) {
        case YWBtnType_preview:
        {
            
            [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            
            [self setTitle:@"预约" forState:UIControlStateNormal];
            
            self.backgroundColor = mainColor;
        }
            break;
        case YWBtnType_havePreviewed:
        {
            
            [self setTitle:@"已预约" forState:UIControlStateNormal];
            
            [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
            
//            self.backgroundColor = YWColor(248, 248, 248);
            self.backgroundColor = [UIColor darkGrayColor];
        }
            break;
        case YWBtnType_review:
        {
            
            [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            
            [self setTitle:@"播放" forState:UIControlStateNormal];
            
            self.backgroundColor = mainColor;
        }
            break;
        case YWBtnType_live:
        {
            
            [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            
            [self setTitle:@"进入" forState:UIControlStateNormal];
            
            self.backgroundColor = mainColor;
        }
            break;
            
        default:
            break;
    }

}




-(void)setIsSelect:(BOOL)isSelect{
    
    _isSelect = isSelect;
    
    
    if (!isSelect) {
        
        if (self.isPreview) {
            
            [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            
            [self setTitle:@"预约" forState:UIControlStateNormal];
            
            self.backgroundColor = mainColor;
        }
        else{
            
            if (self.isAddOptional) {
                
                [self setTitleColor:YWColor(255, 90, 0) forState:UIControlStateNormal];
                
                [self setTitle:@"加自选" forState:UIControlStateNormal];
                
                self.backgroundColor = [UIColor whiteColor];
            }
            else{
                
                [self setTitleColor:YWColor(255, 90, 0) forState:UIControlStateNormal];
                
                [self setTitle:@"关注" forState:UIControlStateNormal];
                
                self.backgroundColor = [UIColor whiteColor];
                
            }
            
            
            
        }
        
        
        
        self.layer.borderWidth = 1;
        
    }
    else{
        
        if (self.isPreview) {
            
            [self setTitle:@"已预约" forState:UIControlStateNormal];
        }
        else{
            
            if (self.isAddOptional) {
                
                [self setTitle:@"删自选" forState:UIControlStateNormal];
            }
            else{
                
                [self setTitle:@"已关注" forState:UIControlStateNormal];
                
            }
            
            
        }
        [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        
        
        self.backgroundColor = YWColor(248, 248, 248);
        
        self.layer.borderWidth = 0;
    }
    
}

-(void)setHighlighted:(BOOL)highlighted{
    
}

@end
